﻿using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using MQ.Core.Common;
using MQ.Core.Admin.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MQ.Core.Admin
{
    /// <summary>
    /// api控制器基类
    /// </summary>
    [ApiController]
    [LoginFilter]
    [EnableCors("LimitRequests")]
    public abstract class ApiController: ControllerBase
    {
        protected virtual ActionResult<ResultMsg> Success(object data)
        {
            return ResultMsg.Ok(data);
        }
        protected virtual ActionResult<ResultMsg> Success()
        {
            return ResultMsg.Ok();
        }
        protected virtual ActionResult<ResultMsg> Success(string msg)
        {
            return ResultMsg.Ok(msg);
        }

        protected virtual ActionResult<ResultMsg> Success(Pagination pagination,object data)
        {
            return ResultMsg.Ok(new { data, pagination.total, pagination.pageCount });
        }
    }
}
